const Contact = require("../models/Contact");
exports.addContact = async function (data) {
  const ins = await Contact.create(data);
  return ins.toJSON()
};

exports.deleteContact = async function (id) {
    await Contact.destroy({                  
        where:{
            id
        }
    })
};

exports.updateContact = async function (id,data) {
    await Contact.update(data,{
        where:{
            id
        }
    })
};


//分页查询
exports.findContacts = async function () {

    const result = await Contact.findOne();
    return result.toJSON()
  };
  
  exports.findContactById = async function (id) {
    const result = await Contact.findByPk(id);
    return result.toJSON();
  };
